<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%
  String articleId=request.getParameter("articleId");
String eventIndex=request.getParameter("eventIndex");
%>
<script>
function getJsonEvent_<%=eventIndex%>(articleId){

	 $.ajax({
			url: '/sapfree/servlet/MessageBoradServlet?method=ajaxGetEventByArticleId&articleId='+articleId, 
			dataType: 'text',
			type: "post",
			error:function(XMLHttpRequest,textStatus,errorThrown){alert(errorThrown);},
			success: function(data) {
			     initEventTable_<%=eventIndex%>(data);
			     $("#EventWait_<%=eventIndex%>").hide();
			}
		});
}

function initEventTable_<%=eventIndex%>(data){
   $('.eventTr_<%=eventIndex%>').remove();
	data=eval(data);
	var s="";
     for(i=0;i<data.length;i++){
         s+=initEventTR_<%=eventIndex%>(data[i]);
     } 
     $("#EventWait_<%=eventIndex%>").after(s);  
}

function initEventTR_<%=eventIndex%>(message){
 
    var s="";
    s+="<tr class=\"eventTr_<%=eventIndex%>\"><td width=\"25%\" height=\"25\" class=\"blackBold14\">"+message.el_date+"</td>";  
    s+="  <td width=\"75%\" class=\"blackNormal14\" align=\"left\">";   
    s+=message.el_content+"</td>"    
    s+=" <td width=\"10%\" height=\"25\" class=\"blackNormal12\"></td></tr>" ; 
    return s;
}
var dlg;
  function showAddEvent_<%=eventIndex%>() {	
	  dlg=new J.ui.dialog({
		    id:'123',
		    html:document.getElementById('eventAddDiv_<%=eventIndex%>'),
		    width:500,
		    height:300,
		    title: '添加大事记',
		    cover:false,
		    btns:false
	    });
	    $("#eventAddDiv_<%=eventIndex%>").show();
	    dlg.ShowDialog();
  } 
  
  function subEvent_<%=eventIndex%>(){
  		 $.ajax({
			url: '/sapfree/servlet/MessageBoradServlet?method=submitEvent&articleId=<%=articleId %>', 
			type: "post",
			data: {"da_el_articleuuid":$("#da_el_articleuuid_<%=eventIndex%>").val(),da_el_date:$("#da_el_date_<%=eventIndex %>").val(),da_el_content:$("#da_el_content_<%=eventIndex %>").val()},
			error:function(XMLHttpRequest,textStatus,errorThrown){alert(errorThrown);},
			success: function(data) {
			     dlg.cancel();
			     $("#EventWait_<%=eventIndex%>").show();
			     getJsonEvent_<%=eventIndex%>('<%=articleId%>');
			}
		});
    
  }
</script>
      <table border="0" cellpadding="0" cellspacing="1" width="98%" bgcolor="#666666">
      <tr>
      	<td align="center" bgcolor="#FFFFFF">
         
      
      
<table border="0" cellpadding="0" cellspacing="0" width="98%" id="EventList_<%=eventIndex %>">
            	<tr>
                	<td height="30" colspan="2" class="blackBold14"><img src="../images/chart_bar_edit.png">&nbsp;大事记</td>
                </tr>
                
                 <tr id="EventWait_<%=eventIndex%>"> 
					 <td height="30" colspan="3" style="font-size:12px" align=center><img src="../include/images/loading.gif" /> 加载中……</td>
				  </tr>
  
              
              
              
                
                <tr>
                	<td height="35" colspan="2" class="blackNormal12">
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    	<tr>
                        	<td width="49%" align="right" height="35">&nbsp;</td>
                            <td width="2%"></td>
                            <td width="49%" align="left">
                            <table border="0" cellpadding="0" cellspacing="0" width="80">
                                <tr>
                                    <td width="80" height="20" bgcolor="f6891f" align="center" style="cursor:hand;">
                                        <span style="color:#FFFFFF; font-weight:bold; font-size:12px;" onclick="showAddEvent_<%=eventIndex %>('<%=articleId %>')">添加大事记</span>                            		</td>
                                </tr>
                            </table>                            </td>
                        </tr>
                        <tr><td height="10"></td></tr>
                    </table>                    </td>
                </tr>
            </table>
            
            
       </td>
     </tr>
     </table>
     <div style="display:none;" id="eventAddDiv_<%=eventIndex%>">
		<div style="margin:5px;align:center;border:0px solid red;margin-top:50px;margin-left:80px;">
		    <form id="form1_<%=eventIndex %>">
		    <input type="hidden" value="<%=articleId %>" name="da_el_articleuuid_<%=eventIndex %>" id="da_el_articleuuid_<%=eventIndex %>"/>
			    事件时间：<input type="text" name="da_el_date_<%=eventIndex %>" id="da_el_date_<%=eventIndex %>"><br/>
			    事件描述：<textArea name="da_el_content_<%=eventIndex %>" id="da_el_content_<%=eventIndex %>"></textArea>
			    <div > 
			   
			    <table border="0" cellpadding="0" cellspacing="10" width="240" >
                  <tr>
                     <td width="120" height="20" bgcolor="f6891f" align="center" style="cursor:hand;" onclick="subEvent_<%=eventIndex %>()">
			        	<span style="color:#FFFFFF; font-weight:bold; font-size:12px;" >保存</span>
					</td>
					<td width="120" height="20" bgcolor="f6891f" align="center" style="cursor:hand;" onclick="dlg.cancel();">
			       		 <span style="color:#FFFFFF; font-weight:bold; font-size:12px;" >取消</span>
			        </td>
			        </tr>
			    </table>
			    
			    </div>
		    </form>
		</div>
	</div>
     <script>
     getJsonEvent_<%=eventIndex%>('<%=articleId%>');
     </script>